﻿@using LanDBom.Models
@{
    ViewBag.Title = "pricing_New_2";
}
@section styles{
    <style>
        th{
            text-align:center;
        }
        #bigdiv{
            overflow:scroll;
            margin-left:15px;
            height:450px;
        }
        #HJ_CP_wl_table {
            width:700px;
        }
        #HJ_CP_wl_table th{
        }
        HJ_CP_gys_ta{

        }
        #HJ_CLJGHS {
            display: none;
            width: 660px;
            height: 440px;
            background-color: #E8ECF6;
            position: fixed;
            left: 300px;
            top: 200px;
            z-index: 1000;
            border: 1px solid black;
        }
        #HJ_CLJGHS_zlm{
            height:360px;
            margin-bottom:5px;
            padding-right:0px;
        }
        #HJ_CLJGHS_jss {
            padding-left: 0px;
        }
        #HJ_CLJGHS_jss>div{
            width:100%;
            height:100%;
            background-color:white
        }
        #HJ_CLJGHS_zlm div{
            height:10%;
            text-align:center;
            line-height:36px;
        }
        #HJ_CLJGHS_wlm {
            height: 40px;
            line-height: 40px;
            font-weight: bolder;
            background-color: coral;
            color: white;
                
        }
        #ZB_ZC_table select{
            width:100px;
        }
        #HJ_CLJGHS_jss table{
            width: 100%;
        }
        #ZB_MS_table td{
            width:25%
        }
        #ZB_ZC_table td {
            width: 20%
        }
        #ZZ_SYZX_tab1 td{
            width:16.6%;
        }
        #ZZ_SYZX_tab1 input{
            width:100%;
        }
        #ZZ_SYZX_tab1 select {
            width: 100%;
        }
    </style>
}
<from>
    <fieldset class="boun">
        <label id="HJ_CP_sqd" class="len">物料核价</label>
        <div class="row">
            <div id="HJ_CL_TJ" class="col-2">提交</div>
            <div id="HJ_CL_FHWL" class="col-2">返回</div>
        </div>
        <div class="row">
            <div id="bigdiv" class="col-8">
                <table id="HJ_CP_wl_table">
                    <thead>
                        <tr>
                            <th><input type="checkbox" /></th>
                            <th>物料名称</th>
                            <th>料号</th>
                            <th>物料分类</th>
                            <th>供应商</th>
                            <th>实际价格</th>
                            <th>理论价格</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody id="HJ_CP_tb">
                    </tbody>
                </table>
            </div>
            <div class="col-3">
                <div class="row">
                    <div class="col-5"><span id="HJ_CP_cksy">查看所有供应商回价</span></div>
                    <div class="col-5">
                        <select id="HJ_CP_cktj">
                            <option value="0">--请选择--</option>
                            <option value="1">回价最低</option>
                            <option value="2">接近理论价格</option>
                            <option value="3">回价最高</option>
                        </select>
                    </div>
                    <div class="col-5"><span id="HJ_CP_jgsx">价格升序</span></div>
                    <div class="col-5"><span id="HJ_CP_jgjx">价格降序</span></div>
                    <div class="col-5"><span id="HJ_CP_yjxz">一键选择</span></div>
                    <div class="col-5"><span id="HJ_CP_yjtj">一键提交</span></div>
                </div>
                <table id="HJ_CP_gys_ta">
                </table>
            </div>
        </div>
    </fieldset>
</from>
<from>
    <div id="HJ_CLJGHS">
        <div id="HJ_CLJGHS_wlm"></div>
        <div id="HJ_CLJGHS_id" style="display:none"></div>
        <div class="row">
            <div class="col-2" id="HJ_CLJGHS_zlm">
                <div>纸质</div>
                <div>塑料</div>
                <div>胶带</div>
                <div>吸塑</div>
                <div>木制品</div>
                <div>复合EPE</div>
            </div>
            <div class="col-10" id="HJ_CLJGHS_jss">
                <div style="display:none" id="纸质" class="jsmb">
                    <div>
                        <select id="ZZ_xzq">
                            <option value="0">请选择</option>
                            <option value="1">纸板</option>
                            <option value="2">水印纸箱</option>
                            <option value="3">水印拉链纸箱纸箱</option>
                        </select>
                    </div>
                    <div>
                        <div id="ZZ_ZB" style="display:block">
                            <table id="ZB_MS_table">
                                <tr>
                                    <td>
                                        <select id="ZB_ms">
                                            <option>瓦楞类型</option>
                                            @foreach (var item in ViewBag.ListZBxx as List<libray>)
                                            {
                                                if (@item.ST_ID == 10)
                                                {
                                                    <option value="@item.LB_fne">@item.LB_fne</option>
                                                }
                                            }
                                        </select>
                                    </td>
                                    <td>厚度:<span id="ZB_HD"></span></td>
                                    <td>加工费:<span id="ZB_jgf"></span></td>
                                    <td>损耗:<span id="ZB_sh"></span></td>
                                </tr>
                            </table>
                            <div>
                                <table id="ZB_ZC_table">
                                    <thead>
                                        <tr>
                                            <td>面纸</td>
                                            <td>
                                                <select class="ZB_CS">
                                                    <option>—请选择—</option>
                                                    @foreach (var item in ViewBag.ListPP as List<parice>)
                                                    {
                                                        if (@item.PA_Shuxing == 5 && @item.PA_LengBie == "面底纸")
                                                        {
                                                            <option value="@item.PA_Pinpai">@item.PA_Pinpai</option>
                                                        }
                                                    }
                                                </select>
                                            </td>
                                            <td>
                                                <select class="ZB_KZ">
                                                </select>
                                            </td>
                                            <td></td>
                                            <td class="ZB_Unit_price"></td>
                                        </tr>
                                    </thead>
                                    <tbody id="ZB_XZC">
                                    </tbody>
                                    <tfoot>
                                        <tr>
                                            <td>瓦楞</td>
                                            <td>
                                                <select class="ZB_CS">
                                                    <option>—请选择—</option>
                                                    @foreach (var item in ViewBag.ListPP as List<parice>)
                                                    {
                                                        if (@item.PA_Shuxing == 5 && @item.PA_LengBie == "瓦纸")
                                                        {
                                                            <option value="@item.PA_Pinpai">@item.PA_Pinpai</option>
                                                        }
                                                    }
                                                </select>
                                            </td>
                                            <td>
                                                <select class="ZB_KZ">
                                                </select>
                                            </td>
                                            <td></td>
                                            <td class="ZB_Unit_price"></td>
                                        </tr>
                                        <tr>
                                            <td>里纸</td>
                                            <td>
                                                <select class="ZB_CS">
                                                    <option>—请选择—</option>
                                                    @foreach (var item in ViewBag.ListPP as List<parice>)
                                                    {
                                                        if (@item.PA_Shuxing == 5 && @item.PA_LengBie == "面底纸")
                                                        {
                                                            <option value="@item.PA_Pinpai">@item.PA_Pinpai</option>
                                                        }
                                                    }
                                                </select>
                                            </td>
                                            <td>
                                                <select class="ZB_KZ">
                                                </select>
                                            </td>
                                            <td></td>
                                            <td class="ZB_Unit_price"></td>
                                        </tr>
                                    </tfoot>
                                </table>
                                <table>
                                    <tr>
                                        <td>总计</td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td id="ZB_Total_price"></td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                        <div id="ZZ_SYZX" style="display:none">
                            <table id="ZZ_SYZX_tab1">
                                <tr>
                                    <td>
                                        <select>
                                            <option>箱型</option>
                                        </select>
                                    </td>
                                    <td>
                                        <select>
                                            <option>原材料</option>
                                        </select>
                                    </td>
                                    <td>纸板平方价:<span></span></td>
                                    <td>纸板厚度:<span id="ZX_ZBHD"></span></td>
                                    <td>系数:<span></span></td>
                                </tr>
                                
                            </table>
                            <table>
                                <tr>
                                    <td>长:</td>
                                    <td class="wl_c" id="WL_ZX_C"></td>
                                    <td>宽:</td>
                                    <td class="wl_k" id="WL_ZX_K"></td>
                                    <td>高:</td>
                                    <td class="wl_g" id="WL_ZX_G"></td>
                                </tr>
                                <tr>
                                    <td>展开长:</td>
                                    <td id="WL_ZX_ZKC"></td>
                                    <td>展开宽:</td>
                                    <td id="WL_ZX_ZKK"></td>
                                    <td>展开面积</td>
                                    <td id="WL_ZX_ZKMJ"></td>
                                </tr>
                            </table>
                            <table>
                                <tr>
                                    <td>印刷</td>
                                    <td>
                                        <select>
                                            <option>无</option>
                                        </select>
                                    </td>
                                    <td>加工费:<span></span></td>
                                </tr>
                                <tr>
                                    <td>表面处理</td>
                                    <td>
                                        <select>
                                            <option>无</option>
                                        </select>
                                    </td>
                                    <td>加工费:<span></span></td>
                                </tr>
                                <tr>
                                    <td>结合</td>
                                    <td>
                                        <select>
                                            <option>无</option>
                                        </select>
                                    </td>
                                    <td>加工费:<span></span></td>
                                </tr>
                                <tr>
                                    <td>包装</td>
                                    <td>
                                        <select>
                                            <option>无</option>
                                        </select>
                                    </td>
                                    <td>加工费:<span></span></td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
                <div style="display:none;overflow:auto;height:360px;" id="木质" class="jsmb">
                    <table>
                        <tr>
                            <td>长</td>
                            <td><input type="number" id="MZ_C" /></td>
                            <td>宽</td>
                            <td><input type="number" id="MZ_K" /></td>
                            <td>高</td>
                            <td><input type="number" id="MZ_G" /></td>
                        </tr>
                    </table>
                    <table>
                        <thead>
                            <tr>
                                <th colspan="12">
                                    木材费
                                </th>
                            </tr>
                            <tr>
                                <th rowspan="2">序号</th>
                                <th rowspan="2">品名</th>
                                <th rowspan="2">材料类别</th>
                                <th colspan="4">线板尺寸</th>
                                <th rowspan="2">数量</th>
                                <th rowspan="2">m³</th>
                                <th rowspan="2">损耗</th>
                                <th>材料含税单价</th>
                                <th>材料费</th>
                            </tr>
                            <tr>
                                <th>长</th>
                                <th>宽</th>
                                <th>厚</th>
                                <th>实际厚度</th>
                                <th>RMB/m3</th>
                                <th>RMB/pcs</th>
                            </tr>
                        </thead>
                        <tbody id="MZ_MCF">
                            <tr>
                                <td></td>
                                <td><input type="text" style="width:60px;height:25px" /></td>
                                <td>
                                    <select class="MZ_CL" style="width:60px;height:25px" id="MZ_CL">
                                        <option>请选择材料</option>
                                        @foreach (var item in ViewBag.parice as List<parice>)
                                        {
                                            if (item.PA_Shuxing == 1)
                                            {
                                                <option value="@item.PA_ZhongL">@item.PA_ZhongL</option>
                                            }

                                        }
                                    </select>
                                </td>
                                <td><input type="number" class="MZ_gg" style="width:60px;height:25px" /></td>
                                <td><input type="number" class="MZ_gg" style="width:60px;height:25px" /></td>
                                <td><input type="number" class="MZ_gg" style="width:60px;height:25px" /></td>
                                <td><input type="number" class="MZ_gg" style="width:60px;height:25px" /></td>
                                <td><input type="number" class="MZ_gg" style="width:60px;height:25px" /></td>
                                <td class="MZ_TJ"></td>
                                <td></td>
                                <td></td>
                                <td class="MZ_MCF"></td>
                                <td><a href="#" id="MZ_CZ">添加</a></td>
                            </tr>
                        </tbody>
                        <tfoot>
                            <tr>
                                <th>合计</th>
                                <th colspan="7"></th>
                                <th id="ALL_MCTJ"></th>
                                <th colspan="2"></th>
                                <th id="ALL_MCF"></th>
                            </tr>
                        </tfoot>
                    </table>
                    <hr />
                    <table style="text-align:center">
                        <thead>
                            <tr>
                                <th colspan="12">
                                    辅料费
                                </th>
                            </tr>
                            <tr>
                                <th>序号</th>
                                <th>名称</th>
                                <th>数量</th>
                                <th>材料含税单价</th>
                                <th>材料费</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody id="MZ_MCF">
                            <tr>
                                <td></td>
                                <td>
                                    <select style="width:60px;height:25px" id="MZ_FL">
                                        <option>请选择材料</option>
                                        @foreach (var item in ViewBag.parice as List<parice>)
                                        {
                                            if (item.PA_Shuxing == 6)
                                            {
                                                <option value="@item.PA_T">@item.PA_ZhongL</option>
                                            }

                                        }
                                    </select>
                                </td>
                                <td><input type="number" style="width:60px;height:25px" id="MZ_FLSL" /></td>
                                <td></td>
                                <td class="MZ_FLF"></td>
                                <td><a href="#" id="MZ_FLH">添加</a></td>
                            </tr>
                        </tbody>
                        <tfoot>
                            <tr>
                                <th>合计</th>
                                <th colspan="3"></th>
                                <th id="ALL_FLF"></th>
                            </tr>
                        </tfoot>
                    </table>
                    <hr />
                    <table style="text-align:center">
                        <thead>
                            <tr>
                                <th colspan="2">
                                    加工费
                                </th>
                            </tr>
                            <tr>
                                <th>工序</th>
                                <th>费用</th>
                                <th>操作</th>
                            </tr>
                            <tr>
                                <td>
                                    <select style="width:60px;height:25px" id="MZ_RG" >
                                        <option value=0>请选择</option>
                                        @foreach (var item in ViewBag.ListZBxx as List<libray>)
                                        {
                                            if (item.ST_ID ==7)
                                            {
                                                <option value="@item.LB_jia">@item.LB_fne</option>
                                            }

                                        }
                                    </select>
                                </td>
                                <td id="MZ_RGF"></td>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td><input type="text" style="width:60px;height:25px"/></td>
                                <td><input type="number" class="MZ_jgf" style="width:60px;height:25px"/></td>
                                <td><a href="#" id="MZ_JGFH">添加</a></td>
                            </tr>
                        </tbody>
                        <tfoot>
                            <tr>
                                <th>合计</th>
                                <th id="ALL_jgf"></th>
                            </tr>
                        </tfoot>
                    </table>
                    <hr />
                    <table>
                        <thead>
                            <tr>
                                <th colspan="2">
                                    运输费
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>运输费</td>
                                <td><input type="number" id="MZ_YSF" class="MZ_YS" /></td>
                            </tr>
                            <tr>
                                <td>装车数量</td>
                                <td><input type="number" id="MZ_ZCSL" class="MZ_YS" /></td>
                            </tr>
                            <tr>
                                <td>运输费小计</td>
                                <td id="MZ_YSFXJ"></td>
                            </tr>
                        </tbody>
                    </table>
                    <table>
                        <thead>
                            <tr>
                                <th colspan="2">
                                    热处理费用
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>运输费</td>
                                <td><input type="number" id="MZ_YSF" class="MZ_YS" /></td>
                            </tr>
                            <tr>
                                <td>装车数量</td>
                                <td><input type="number" id="MZ_ZCSL" class="MZ_YS" /></td>
                            </tr>
                            <tr>
                                <td>运输费小计</td>
                                <td id="MZ_YSFXJ"></td>
                            </tr>
                        </tbody>
                    </table>
                    <hr />
                </div>

                <div style="display:none" id="塑料" class="jsmb">
                    <table>
                        <tr>
                            <td>
                                <select id="sl_ms">
                                    <option>种类</option>
                                    @foreach (var item in ViewBag.ListPO as List<Projectpr>)
                                    {
                                        <option value="@item.PR_name">@item.PR_name</option>
                                    }
                                </select>
                            </td>
                            <td></td>
                            <td></td>
                        </tr>
                    </table>
                    <table id="SL_WLZC">
                        
                    </table>
                    <table>
                        <tr>
                            <td rowspan="2">规格</td>
                            <td>长:</td>
                            <td id="SL_gg_C" class="wl_c"></td>
                            <td>宽:</td>
                            <td id="SL_gg_K" class="wl_k"></td>
                            <td>材料面积:</td>
                            <td id="SL_gg_dx" class="wl_mj"></td>
                        </tr>
                        <tr>
                            <td>平方克重:</td>
                            <td><input type="number" id="SL_gg_Z" class="SL_gg" style="width:60px" />/g</td>
                            <td>物料重量</td>
                            <td id="SL_wlzl"></td>
                            <td>物料克价</td>
                            <td id="SL_wldj"></td>
                        </tr>
                        <tr>
                            <td><input type="checkbox" id="SL_CM" value="吹膜" class="SL_GGF" />吹膜</td>
                            <td class="SL_FYZC"></td>
                            <td><input type="checkbox" id="SL_ZD" value="制袋" class="SL_GGF" />制袋</td>
                            <td class="SL_FYZC"></td>
                            <td>材料费:</td>
                            <td class="SL_FYZC" id="SL_CLF"></td>
                        </tr>
                        <tr>
                            <td>合计</td>
                            <td id="SL_HJ"></td>
                        </tr>
                    </table>

                </div>
            </div>
        </div>
        <div style="text-align:center;height:30px">
            <button id="HJ_CLJGHS_qd">确定</button>&emsp;
            <button id="HJ_CLJGHS_fh">返回</button>
        </div>
    </div>
</from>




@section scripts
{
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script>
        $(function () {
            ajax_WL_INF()
            ajax_INF()
            Supplier_selection()
            Add_HJ_CL()
            Back_FM()
            //生成当前时间
            function time() {
                var now = new Date($.now());
                var year = (now.getFullYear()).toString();
                var month = (now.getMonth() + 1).toString();
                var date = (now.getDate()).toString();
                var qishi_time = year + "/" + month + "/" + date
                return qishi_time
            }
            //查找采购询价中所有种类的物料
            function ajax_WL_INF() {
                $.ajax({
                    url: '/Procure/pricing_New_2',
                    type: 'GET',
                    data: {"state": 1 },
                    success: function (data) {
                        createTR(data);
                    },
                    error: function () {
                        alert('Request Error')
                    }
                })
            }
            //打印物料信息
            function createTR(data) {
                var now = new Date($.now());
                var year = (now.getFullYear()).toString();
                var month = (now.getMonth() + 1).toString();
                var date = (now.getDate()).toString();
                var qishi_time = year + "/" + month + "/" + date
                $('#HJ_CP_tb tr').remove();
                $('#HJ_CP_gys_ta thead').remove();
                $('#HJ_CP_gys_ta tbody').remove();
                $.each(data, function (i, item) {
                    var $tr = $(`
                                   <tr>
                                       <th><input type="checkbox" /></th>
                                       <th id="HJ_CL_WLid_c1" >${item.Inf_id}</th>
                                       <th id="HJ_CL_WLM_c1">${item.Inf_wu}</th>
                                       <th id="HJ_CL_WLH_c1">${item.Inf_liao}</th>
                                       <th id="HJ_CL_ZL_c1">${item.MA_fne}</th>
                                       <th id="HJ_CL_GYS_c1">${item.Inf_gong}</th>
                                       <th id="HJ_CL_HJ_c1">${item.Inf_huiP}</th>
                                       <th></th>
                                       <th><a href="#" id="HJ_LLCBHS">理论成本核算</a></th>
                                  </tr>
                              `);
                    $('#HJ_CP_tb').append($tr);

                    var $tr = $(`
                                 <thead>
                                     <tr>
                                         <th colspan="5" class="HJ_CP_WLM" id="${item.Inf_liao}bt" style="font-size:150%">${item.Inf_wu}</th>
                                     </tr>
                                     <tr>
                                         <th><input type="checkbox" class="HJ_CP_qxgys"/></th>
                                         <th>供应商</th>
                                         <th>供应商回价</th>
                                         <th>理论价格</th>
                                         <th>价格差</th>
                                     </tr>
                                 </thead >
                                 <tbody id="HJ_CP_gyshj">

                                 </tbody>
                            `);
                    $('#HJ_CP_gys_ta').append($tr);

                })
            }
            //查找所有询价信息
            function ajax_INF() {
                $.ajax({
                    url: '/Procure/pricing_New_2',
                    type: 'GET',
                    data: {"state": 2 },
                    success: function (data) {
                        createHJ_TR(data);
                    },
                    error: function () {
                        alert('Request Error')
                    }
                })
            }
            //打印所有询价信息
            function createHJ_TR(data,num) {
                $('#HJ_CP_gyshj tr').remove();
                $.each(data, function (i, item) {
                    var llcb = 0
                    var $tr = $(`
                      <tr>
                          <th><input type="checkbox" name="${item.Inf_wu}"/></th>
                          <th id="HJ_CP_gys_x1">${item.Inf_gong}</th>
                          <th id="HJ_CP_hj_x1">${item.Inf_huiP}</th>
                          <th id="${item.Inf_wu}" class="${item.Inf_wu}"></th>
                          <th id="${item.Inf_wu}+cj"></th>
                          <th id="HJ_CP_w_x1" style="display:none">${item.Inf_wu}</th>
                          <th id="HJ_CP_l_x1" style="display:none">${item.Inf_liao}</th>
                          <th id="HJ_CP_i_x1" style="display:none">${item.Inf_id}</th>
                      </tr>
                  `);
                    $('th[class="HJ_CP_WLM"]').each(function (i, obj) {
                        if (obj.id == item.Inf_liao + "bt") {
                            console.log(obj.id)
                            console.log(item.Inf_liao + "bt")
                            $('th[id="' + item.Inf_liao +'bt"]').parent().parent().next().append($tr)
                        }
                    })
                    if (num == 2) {
                        if ($("th[id='" + item.Inf_id + "+cj']").text() > 120 || $("th[id='" + item.Inf_id + "+cj']").text(bfb2)<80)
                        $("th[id='" + item.Inf_id + "+cj']").parent().remove()
                    }
                })

            }
            //将选择的物料回价入库
            function Add_HJ_CL() {
                $(document).on("click", "#HJ_CL_TJ", function () {

                    var now = new Date($.now());
                    var year = (now.getFullYear()).toString();
                    var month = (now.getMonth() + 1).toString();
                    var date = (now.getDate()).toString();
                    var qishi_time = year + "/" + month + "/" + date

                    var WLwcXJ = []
                    var BZJG = []
                    var LDGX = []
                    var BZJG_CD = $(':checkbox:checked').parent().parent().length;
                    if (BZJG_CD < 0) {
                        alert("请选择一个供应商回价")
                    }
                    else {
                        $(':checkbox:checked').parent().parent().each(function (i, item) {
                            var shixiao = $("th[id='HJ_CL_SX_c1']", item).val()
                            BZJG.push({
                                Nd_Gong: $("th[id='HJ_CL_GYS_c1']", item).text(),
                                Nd_wuLiao: $("th[id='HJ_CL_WLM_c1']", item).text(),
                                Nd_jiage: $("th[id='HJ_CL_HJ_c1']", item).text(),
                                Nd_shengxiao: $("th[id='HJ_CL_FQ_c1']", item).text(),
                                Nd_shixiao: shixiao

                            })
                            WLwcXJ.push({
                                Inf_id: $("th[id='HJ_CL_WLid_c1']", item).text(),
                                Inf_zhuang: "完成"
                            })

                            LDGX.push({
                                FM_name: qishi_time,
                                FM_bai: $("th[id='HJ_CL_WLH_c1']", item).text()
                            })
                            console.log(WLwcXJ);
                        })
                        $.ajax({
                            url: "/Procure/AddLanjilu",
                            type: 'POST',
                            data: JSON.stringify(LDGX),
                            contentType: "application/json;charset=utf-8",
                            dataType: "json",
                            success: function (text) {
                                ajax_WL_INF()
                            },
                            error: function (text) {
                                ajax_WL_INF()
                            }
                        })
                        $.ajax({
                            url: "/Procure/AddNdardo_CP",
                            type: 'POST',
                            data: JSON.stringify(BZJG),
                            contentType: "application/json;charset=utf-8",
                            dataType: "json",
                            success: function (text) {
                                alert(text)
                            },
                            error: function (text) {
                                alert("系统错误" + text);
                            }
                        })
                        $.ajax({
                            url: "/Procure/Modify_INF_zhuang",
                            type: 'POST',
                            data: JSON.stringify(WLwcXJ),
                            contentType: "application/json;charset=utf-8",
                            dataType: "json",
                            success: function (text) {
                                ajax_WL_INF()
                            },
                            error: function (text) {
                                ajax_WL_INF()
                            }
                        })

                    }
                })

            }
            //供应商回价全选
            function Supplier_selection() {
                $(document).on("click", "#HJ_CP_yjxz", function () {
                    $("#HJ_CP_gys_ta input[type=checkbox]").attr("checked", true)
                    $(".HJ_CP_qxgys").attr("checked", false)
                })
                //$(document).on("click", ".HJ_CP_qxgys", function (e) {
                //    var checkbox = $(e.target).parent().parent().parent().next().children().get()
                //    if ($(e.target).attr("checked", true)) {
                //        console.log(checkbox)
                //        $.each(checkbox, function (i,item) {

                //        })
                //    }
                //})
            }
            //返回物料表
            function Back_FM() {
                $(document).on("click", "#HJ_CL_FHWL", function () {
                    window.location.href = "/Formations/Index"
                })
            }
            //打开计算页面
            function Open_calculation_page(e) {
                $("#HJ_CLJGHS").css({ "display": "block" })
                var wlname = e.parent().parent().children().eq(2).text()
                var zlname = e.parent().parent().children().eq(4).text()
                var infid = e.parent().parent().children().eq(1).text()
                $("#HJ_CLJGHS_wlm").text(wlname)
                $("#HJ_CLJGHS_id").text(infid)
                $("#HJ_CLJGHS_zlm div").each(function (i, item) {
                    if ($(item).text() == zlname) {
                        $(item).css({ "background-color": "white", "color":"coral"})
                    }
                })
                $("#HJ_CLJGHS_jss div").each(function (j, obj) {
                    if (obj.id == zlname) {
                        $(obj).css({ "display": "block"})
                    }
                })
                $.ajax({
                    url: "/Procure/pricing_New_2",
                    type: 'GET',
                    data: { "state": 6, "ZLX": wlname },
                    success: function (data) {
                        $.each(data, function (i, item) {
                            var c= $(".wl_c").text(item.FM_long)
                            var k= $(".wl_k").text(item.FM_kuan)
                            var g = $(".wl_g").text(item.FM_gao)
                        })
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //点击关闭价格计算面板
            $(document).on("click", "#HJ_CLJGHS_fh", function () {
                $("#HJ_CLJGHS").css({ "display": "none" })
                $(".jsmb").css({"display":"none"})
            })
            //点击调用打开价格计算面板的方法
            $(document).on("click", "#HJ_LLCBHS", function (e) {
                Open_calculation_page($(e.target))
            })
            //点击调用方法查找所有询价信息
            $(document).on("click", "#HJ_CP_cksy", function () {
                ajax_INF()
            })
            //下拉框改变查找的询价信息
            $(document).on("change", "#HJ_CP_cktj", function () {
                var HJ_CP_cktj = $("#HJ_CP_cktj").val()
                console.log(HJ_CP_cktj)
                if (HJ_CP_cktj != 0 && HJ_CP_cktj != 2) {
                    $.ajax({
                        url: '/Procure/Pricing_New',
                        type: 'GET',
                        data: { "HJ_CP_cktj": HJ_CP_cktj, "APP_bian": HJ_CP_sqd, "state": 3 },
                        success: function (data) {
                            createHJ_TR(data);
                        },
                        error: function () {
                            alert('Request Error')
                        }
                    })
                }
                else if (HJ_CP_cktj==2) {
                    createHJ_TR(data,2)
                }
            })
            //升序排列
            $(document).on("click", "#HJ_CP_jgsx", function () {
                $.ajax({
                    url: '/Procure/Pricing_New',
                    type: 'GET',
                    data: { "APP_bian": HJ_CP_sqd, "state": 4 },
                    success: function (data) {
                        createHJ_TR(data);
                    },
                    error: function () {
                        alert('Request Error')
                    }
                })
            })
            //降序排列
            $(document).on("click", "#HJ_CP_jgjx", function () {
                $.ajax({
                    url: '/Procure/Pricing_New',
                    type: 'GET',
                    data: { "APP_bian": HJ_CP_sqd, "state": 5 },
                    success: function (data) {
                        createHJ_TR(data);
                    },
                    error: function () {
                        alert('Request Error')
                    }
                })
            })
            //修改选择的供应商回价的状态
            $(document).on("click", "#HJ_CP_yjtj", function () {
                var BZJG = []
                var BZJG_CD = $('#HJ_CP_gys_ta :checkbox:checked').parent().parent().length;
                if (BZJG_CD < 0) {
                    alert("请选择一个供应商回价")
                }
                else {
                    $('#HJ_CP_gys_ta :checkbox:checked').parent().parent().each(function (i, item) {
                        BZJG.push({
                            Inf_id: $("th[id='HJ_CP_i_x1']", item).text(),
                            Inf_zhuang:"已确认"
                        })
                        console.log("共" + BZJG.length + "数据");
                        console.log(BZJG);
                    })
                    $.ajax({
                        url: "/Procure/Modify_INF_zhuang",
                        type: 'POST',
                        data: JSON.stringify(BZJG),
                        contentType: "application/json;charset=utf-8",
                        dataType: "json",
                        success: function (text) {
                            alert(text)
                            ajax_WL_INF()
                        },
                        error: function (text) {
                            alert("系统错误" + text);
                            ajax_WL_INF()
                        }
                    })

                }
            })

        })
        //纸制
        $(function () {
            //显示单瓦楞和双瓦楞
            function WL() {
                var ds = $("#ZB_ms").val()
                var ds2 = ds.length
                var $tfoot=$(`<tr>
                                <td>瓦楞</td>
                                <td>
                                    <select class="ZB_CS">
                                        <option>—请选择—</option>
                                        @foreach (var item in ViewBag.ListPP as List<parice>)
                                        {
                                            if (@item.PA_Shuxing == 5 && @item.PA_LengBie == "瓦纸")
                                            {
                                                <option value="@item.PA_Pinpai">@item.PA_Pinpai</option>
                                            }
                                        }
                                    </select>
                                </td>
                                <td>
                                    <select class="ZB_KZ">
                                    </select>
                                </td>
                                <td></td>
                                <td class="ZB_Unit_price"></td>
                            </tr>
                            <tr>
                                <td>里纸</td>
                                <td>
                                    <select class="ZB_CS">
                                        <option>—请选择—</option>
                                        @foreach (var item in ViewBag.ListPP as List<parice>)
                                        {
                                            if (@item.PA_Shuxing == 5 && @item.PA_LengBie == "面底纸")
                                            {
                                                <option value="@item.PA_Pinpai">@item.PA_Pinpai</option>
                                            }
                                        }
                                    </select>
                                </td>
                                <td>
                                    <select class="ZB_KZ">
                                    </select>
                                </td>
                                <td></td>
                                <td class="ZB_Unit_price"></td>
                            </tr>`)
                var $tbody = $(`
                    <tr class="Shuangwa" id="Shuangwa1">
                        <td>瓦楞</td>
                        <td>
                            <select class="ZB_CS">
                                <option>—请选择—</option>
                                @foreach (var item in ViewBag.ListPP as List<parice>)
                                {
                                    if (@item.PA_Shuxing == 5 && @item.PA_LengBie == "瓦纸")
                                    {
                                        <option value="@item.PA_Pinpai">@item.PA_Pinpai</option>
                                    }
                                }
                            </select>
                        </td>
                        <td>
                            <select class="ZB_KZ">
                            </select>
                        </td>
                        <td></td>
                        <td class="ZB_Unit_price"></td>
                    </tr>

                    <tr class="Shuangwa"  id="Shuangwa2" >
                        <td>底纸</td>
                        <td>
                            <select class="ZB_CS">
                                <option>—请选择—</option>
                                @foreach (var item in ViewBag.ListPP as List<parice>)
                                {
                                    if (@item.PA_Shuxing == 5 && @item.PA_LengBie == "面底纸")
                                    {
                                        <option value="@item.PA_Pinpai">@item.PA_Pinpai</option>
                                    }
                                }
                            </select>
                        </td>
                        <td>
                            <select class="ZB_KZ">
                            </select>
                        </td>
                        <td></td>
                        <td class="ZB_Unit_price"></td>
                    </tr>
                    `)
                if (ds == "N/A") {
                    $("#ZB_ZC_table tbody tr").remove()
                    $("#ZB_ZC_table tfoot tr").remove()
                }
                else {
                    if (ds2 == "1") {
                        $("#ZB_ZC_table tbody tr").remove()
                        $("#ZB_ZC_table tfoot tr").remove()

                        $("#ZB_ZC_table tfoot").append($tfoot)

                    }
                    else if (ds2 == "2") {
                        $("#ZB_ZC_table tbody tr").remove()
                        $("#ZB_ZC_table tfoot tr").remove()

                        $("#ZB_ZC_table tbody").append($tbody)
                        $("#ZB_ZC_table tfoot").append($tfoot)
                    }
                }
            }
            //根据描述找到损耗,加工费和厚度
            function Find_Tear_and_ProcessingCharges() {
                var miaoshu = $("#ZB_ms").val()
                $.ajax({
                    url: "/Procure/paperboard",
                    type: 'GET',
                    data: { "state": 2, "miaoshu": miaoshu},
                    success: function (data) {
                        $.each(data, function (i, item) {
                            $("#ZB_jgf").text(item.LB_jia)
                            $("#ZB_sh").text(item.LB_shun * 0.01)
                            $("#ZB_HD").text(item.LB_Zlei)
                        })
                        Sum_up()
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //获取平方克重
            function Get_SquareGramWeight(e) {
                var pingpai = e.val()
                if (pingpai != null) {
                    $.ajax({
                        url: "/Procure/paperboard",
                        type: 'GET',
                        data: { "state": 3, "pingpai": pingpai },
                        success: function (data) {
                            e.parent().next().children().first().children().remove()
                            $.each(data, function (i, item) {
                                var $tr = $(`<option value="${item.PA_T}+${item.PA_KZ}" >${item.PA_KZ}克--${item.PA_ZhongL}-${item.PA_T}元/吨</option>`);
                                e.parent().next().children().first().append($tr);
                            })
                            Product_price_per_ton(e)
                            Sum_up()
                            
                        },
                        error: function () {
                            alert('Request Error');
                        }
                    })
                }
            }
            //获取产品吨价
            function Product_price_per_ton(e) {
                var zbzl = e.parent().parent().children().eq(2).children().val()
                var text = zbzl;
                if (text != null) {
                    var parts = text.split("+");  // 使用逗号和空格作为分隔符
                    let firstElement = parts[0];
                    let lastElement = parts[parts.length - 1];
                    console.log(firstElement, lastElement)
                    e.parent().parent().children().eq(3).text(firstElement)
                    e.parent().parent().children().eq(4).text(firstElement * 0.000001 * lastElement)
                }
            }
            //计算纸板组成总价格
            function Sum_up() {
                var temp=0
                $(".ZB_Unit_price").each(function (i, item) {
                    temp = temp + $(item).text()*1
                })
                var sum = temp * 1 * (1 + $("#ZB_sh").text() * 1) + $("#ZB_jgf").text() * 1
                $("#ZB_Total_price").text(sum.toFixed(4))
            }
            //改变种类下拉框触发事件
            $(document).on("change", ".ZB_KZ", function (x) {
                Product_price_per_ton($(x.target))
                Sum_up()
            })
            //改变描述下拉框触发事件
            $(document).on("change", "#ZB_ms", function () {
                WL()
                Find_Tear_and_ProcessingCharges()
                Sum_up()
            })
            //改变厂商触发事件---改版种类
            $(document).on("change", ".ZB_CS", function (e) {
                Get_SquareGramWeight($(e.target))
                Sum_up()
            })
        })
        //木制品
        $(function () {
            //计算辅料价格
            function accessory(e) {
                var s = e.val() * 1
                var j = e.parent().next().text() * 1
                e.parent().next().next().text(s * j)
                var sum=0
                $(".MZ_FLF").each(function (i, item) {
                    sum+=$(item).text()*1
                })
                $("#ALL_FLF").text(sum)
            }
            //计算木材体积和价格
            function Calculated_Volume(e) {
                var c = e.parent().parent().children().eq(3).children().val()
                var k = e.parent().parent().children().eq(4).children().val()
                var g = e.parent().parent().children().eq(6).children().val()
                var s = e.parent().parent().children().eq(7).children().val()
                var sh = e.parent().parent().children().eq(9).text()
                var j = e.parent().parent().children().eq(10).text()
                var m3 = c * k * g * s / 1000000000
                e.parent().parent().children().eq(8).text((m3).toFixed(4))
                e.parent().parent().children().eq(11).text(((m3 * j) * (1 + sh * 1)).toFixed(4))
                var sum = 0
                var num=0
                $(".MZ_MCF").each(function (i, item) {
                    sum += $(item).text()*1
                })
                $("#ALL_MCF").text(sum)
                $(".MZ_TJ").each(function (j, obj) {
                    num+=$(obj).text()*1
                })
                $("#ALL_MCTJ").text(num)
            }
            //根据材料类别获取损耗和立方价格
            function Wear_Price_w_ZL(e) {
                var lei = e.val()
                console.log(lei)
                $.ajax({
                    url: "/Procure/woodwork",
                    type: 'GET',
                    data: { "state": 2, "miaoshu": lei },
                    success: function (data) {
                        $.each(data, function (i, item) {
                            e.parent().parent().children().eq(9).text(0.1)
                            e.parent().parent().children().eq(10).text(item.PA_T)

                        })
                        Calculated_Volume(e)
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //新增木材费表格行
            function Add_table_row_Timber(e) {
                var caoz = e.text()
                if (caoz == "添加") {
                    e.text("删除")
                    var $tr = $(`
                                 <tr>
                                    <td></td>
                                    <td><input type="text" style="width:60px;height:25px"/></td>
                                    <td>
                                        <select class="MZ_CL" style="width:60px;height:25px" id="MZ_CL">
                                            <option>请选择材料</option>
                                            @foreach (var item in ViewBag.parice as List<parice>)
                                            {
                                                if (item.PA_Shuxing == 1)
                                                {
                                                    <option value="@item.PA_ZhongL">@item.PA_ZhongL</option>
                                                }
                                            }
                                        </select>
                                    </td>
                                    <td><input type="number" class="MZ_gg" style="width:60px;height:25px"/></td>
                                    <td><input type="number" class="MZ_gg" style="width:60px;height:25px"/></td>
                                    <td><input type="number" class="MZ_gg" style="width:60px;height:25px"/></td>
                                    <td><input type="number" class="MZ_gg" style="width:60px;height:25px"/></td>
                                    <td><input type="number" class="MZ_gg" style="width:60px;height:25px"/></td>
                                    <td class="MZ_TJ"></td>
                                    <td></td>
                                    <td></td>
                                    <td class="MZ_MCF"></td>
                                    <td><a href="#" id="MZ_CZ">添加</a></td>
                                </tr>
                             `);
                    e.parent().parent().parent().append($tr)
                    var sum = 0
                    var num = 0
                    $(".MZ_MCF").each(function (i, item) {
                        sum += $(item).text() * 1
                    })
                    $("#ALL_MCF").text(sum)
                    $(".MZ_TJ").each(function (j, obj) {
                        num += $(obj).text() * 1
                    })
                    $("#ALL_MCTJ").text(num)
                }
                else {
                    e.parent().parent().remove()
                }
            }
            //新增辅件费用表格行
            function Add_table_row_accessory(e) {
                var caoz = e.text()
                if (caoz == "添加") {
                    e.text("删除")
                    var $tr = $(`
                    <tr>
                        <td></td>
                        <td>
                            <select style="width:60px;height:25px" id="MZ_FL">
                                <option>请选择材料</option>
                                @foreach (var item in ViewBag.parice as List<parice>)
                                {
                                    if (item.PA_Shuxing == 6)
                                    {
                                        <option value="@item.PA_T">@item.PA_ZhongL</option>
                                    }

                                }
                            </select>
                        </td>
                        <td><input type="number" style="width:60px;height:25px" id="MZ_FLSL"/></td>
                        <td></td>
                        <td class="MZ_FLF"></td>
                        <td><a href="#" id="MZ_FLH">添加</a></td>
                    </tr>
                             `);
                    e.parent().parent().parent().append($tr)
                    var sum = 0
                    $(".MZ_FLF").each(function (i, item) {
                        sum += $(item).text() * 1
                    })
                    $("#ALL_FLF").text(sum)
                }
                else {
                    e.parent().parent().remove()
                }
            }
            //新增加工费
            function Add_table_row_Processing(e) {
                var caoz = e.text()
                if (caoz == "添加") {
                    e.text("删除")
                    var $tr = $(`
                                <tr>
                                    <td><input type="text" style="width:60px;height:25px"/></td>
                                    <td><input type="number" class="MZ_jgf" style="width:60px;height:25px"/></td>
                                    <td><a href="#" id="MZ_JGFH">添加</a></td>
                                </tr>
                             `);
                    e.parent().parent().parent().append($tr)

                }
                else {
                    e.parent().parent().remove()
                }
            }
            //切换二级分类来触发事件
            function Search_SrocessingFee() {
                var miaoshu = $("#MZP_ms").val()
                $.ajax({
                    url: "/Procure/woodwork",
                    type: 'GET',
                    data: { "state": 1, "miaoshu": miaoshu },
                    success: function (data) {
                        $.each(data, function (i, item) {
                            $("#MZP_jgf").text(item.LB_jia)
                        })
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //计算运输费小计
            function Transportation_charges_subtotal() {
                var num = $("#MZ_ZCSL").val()*1
                var all = $("#MZ_YSF").val() * 1
                console.log(all)
                console.log(num)
                sub=all/num
                $("#MZ_YSFXJ").text(sub)
            }
            //计算总加工费
            function Processing_cost() {
                var sum=0
                $(".MZ_jgf").each(function (i, item) {
                    sum += $(item).val()*1
                })
                var rg= $("#MZ_RGF").text()*1
                $("#ALL_jgf").text(sum+rg)
            }
            $(document).on("keyup", ".MZ_jgf", function (i, item) {
                Processing_cost()
            })
            //修改加工费(木箱/托盘)
            $(document).on("change", "#MZ_RG", function (e) {
                var jia = $(e.target).val()
                var Ztj = $("#ALL_MCTJ").text()
                var jgf_tj = jia * Ztj
                $(e.target).parent().next().text(jgf_tj)
            })
            //输入运输费和装车数量
            $(document).on("keyup", ".MZ_YS", function (e) {
                Transportation_charges_subtotal()
            })
            //辅料费的添加/删除
            $(document).on("click", "#MZ_FLH", function (e) {
                Add_table_row_accessory($(e.target))
            })
            //加工费的添加/删除
            $(document).on("click", "#MZ_JGFH", function (e) {
                Add_table_row_Processing($(e.target))
            })
            //输入辅料数量
            $(document).on("keyup", "#MZ_FLSL", function (e) {
                accessory($(e.target))
            })
            //切换辅料名来切换单价
            $(document).on("change", "#MZ_FL", function (e) {
                var dj = $(e.target).val()
                var s = $(e.target).parent().next().children().val()
                $(e.target).parent().next().next().text(dj)
                $(e.target).parent().next().next().next().text(dj*s)
            })
            //输入木材规格
            $(document).on("keyup", ".MZ_gg", function (e) {
                Calculated_Volume($(e.target))
            })
            //下拉框修改木材的材料类别
            $(document).on("change", "#MZ_CL", function (e) {
                Wear_Price_w_ZL($(e.target))
            })
            //木材费的添加/删除
            $(document).on("click", "#MZ_CZ", function (e) {
                Add_table_row_Timber($(e.target))
            })
            $(document).on("click", "#MZP_ms", function (e) {
                Search_SrocessingFee()
            })
        })
        //塑料制品
        $(function () {
            Calculated_size()
            //计算物料大小
            function Calculated_size() {
                var c = $("#SL_gg_C").text()
                var k = $("#SL_gg_K").text()
                $("#SL_gg_dx").text((0.0001 * c * k).toFixed(4))
            }
            //根据种类搜索加工费损耗
            function change_sl_ProcessingCost() {
                var sl_ms = $("#sl_ms").val()
                console.log(sl_ms)
                $.ajax({
                    url: "/Procure/Plastic_product",
                    type: 'GET',
                    data: { "state": 1, "miaoshu": sl_ms },
                    success: function (data) {
                        Print_plastic_composition(data)
                        Gram_value()
                        Sum_up_W_SL()
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //打印塑料组成
            function Print_plastic_composition(data) {
                $('#SL_WLZC tr').remove();
                $.each(data, function (i, item) {
                    var $tr = $(`
                        <tr style="background-color:#E8ECF6">
                            <td>${item.PA_ZhongL}</td>
                            <td>${item.PR_dai}</td>
                            <td>${item.PA_T}</td>
                            <td class="CL_jg">${item.PA_T * item.PR_dai}</td>
                        </tr>
                    `);
                    $('#SL_WLZC').append($tr);
                })
            }
            //计算物料克价格
            function Gram_value() {
                var sum = 0
                $(".CL_jg").each(function (i, item) {
                    sum += $(item).text()*1
                })
                $("#SL_wldj").text(sum  / 1000000)
            }
            //计算材料重量和价格
            function Calculated_weight_SL() {
                console.log($("#SL_gg_dx").val())
                $("#SL_wlzl").text(($("#SL_gg_Z").val() * $("#SL_gg_dx").text()).toFixed(4))
                $("#SL_CLF").text(($("#SL_wlzl").text() * $("#SL_gg_dx").text()))
            }
            //查找加工费
            function findjgf(e) {
                console.log(e.val())
                $.ajax({
                    url: "/Procure/Plastic_product",
                    type: 'GET',
                    data: { "state": 2, "miaoshu": e.val() },
                    success: function (data) {
                        $.each(data, function (i, item) {

                            e.parent().next().text(($("#SL_wlzl").val() * item.LB_jia / 1000))
                        })
                        Sum_up_W_SL()
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //计算物料价格
            function Sum_up_W_SL() {
                var sum=0
                $(".SL_FYZC").each(function (i, item) {
                    sum+=$(item).text()*1
                })
                console.log(sum+"合计")
                $("#SL_HJ").text(sum)
            }
            //点击添加吹膜或者制袋的加工费
            $(document).on("click", ".SL_GGF", function (e) {
                if ($(e.target).prop("checked")) {
                    findjgf($(e.target))
                }
            })
            //修改克重数量触发
            $(document).on("keyup", "#SL_gg_Z", function (e) {
                Calculated_weight_SL()
                Sum_up_W_SL()
            })
            //点击切换种类
            $(document).on("change", "#sl_ms", function () {
                change_sl_ProcessingCost()
                Sum_up_W_SL()
            })
            $(document).on("change", ".SL_gg", function () {
                Calculated_size()
                Sum_up_W_SL()
            })
        })
        //计算材料理论价格的方法
        $(function () {
            var SH = null //设置变量接受损耗
            var jgf = 0;//设置变量接受加工费
            $(document).on("change", "#JS_ZDJ", function (e) {

                var MK = $(e.target).val();
                var ML = $(e.target).parent().prev().children().first().val();

                $.ajax({
                    url: "/Procure/pricing_New_2",
                    type: 'GET',
                    data: { "MK": MK, "ML": ML, "state": 8 },
                    success: function (data) {
                        JSSH(data)
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
                function JSSH(date) {
                    $.each(date, function (i, item) {
                        SH = item.PA_Sun
                    })
                }
            })
            //点击切换纸板类型，来搜索克重信息
            $(document).on("change", ".JS_HZLX", function (e) {
                var ZLX = $(e.target).val();
                $.ajax({
                    url: '/Procure/pricing_New_2',
                    type: 'GET',
                    data: { "ZLX": ZLX, "state": 6 },
                    success: function (data) {
                        createKEZ(data);
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
                //打印克重信息下拉列表
                function createKEZ(date) {
                    $(e.target).parent().next().children().first().children().first().next().remove()
                    $.each(date, function (i, item) {
                        var $tr = $(`<option value="${item.PA_Pke}" id="CL_ID">${item.PA_Pke}</option>`);
                        $(e.target).parent().next().children().first().append($tr);
                    })
                }
            })
            //点击切换瓦楞系数
            $(document).on("change", ".JS_LB", function (e) {
                var ZLB = $(e.target).parent().parent().children().eq(10).children().val() + $(e.target).parent().parent().children().eq(15).children().val()
                var WLXS = $(e.target).val();
                $(e.target).parent().parent().children().eq(7).text(ZLB)

                $.ajax({
                    url: '/Procure/pricing_New_2',
                    type: 'GET',
                    data: { "WLXS": WLXS, "state": 7 },
                    success: function (data) {
                        createLXKZ(data);
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
                //打印瓦楞的系数信息
                function createLXKZ(date) {
                    $(e.target).parent().next().children().first().children().first().next().remove()
                    $.each(date, function (i, item) {
                        var $tr = $(`<option value="${item.PA_Xishu}" id="CL_ID">${item.PA_Xishu}</option>`);
                        $(e.target).parent().next().children().first().append($tr);
                    })
                }

                $.ajax({
                    url: '/Procure/pricing_New_2',
                    type: 'GET',
                    data: { "ZLX": ZLB, "state": 9 },
                    success: function (data) {
                        JS_JGF(data)
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
                function JS_JGF(data) {
                    $.each(data, function (x, obj) {
                        jgf=obj.PA_Jia
                    })
                }
            })
            //计算面纸/中纸/底纸平方价格
            $(document).on("change", ".JS_ZDJ", function (e) {
                var ycfz = null
                var MK = $(e.target).val();
                var ML = $(e.target).parent().prev().children().first().val();
                var Zancun = $(e.target).next().text()
                var PFJG = $("#CHJG").text()
                $.ajax({
                    url: "/Procure/pricing_New_2",
                    type: 'GET',
                    data: { "MK": MK, "ML": ML, "state": 8 },
                    success: function (data) {
                        JSJG(data)
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
                function JSJG(date) {
                    $.each(date, function (i, item) {
                        ycfz = item.PA_price
                    })
                    var jg = (ycfz * 0.000001 * MK)
                    var x2 = $(e.target).parent().parent().children().first().next().next().next().text()//料号
                    console.log(x2)
                    console.log(jg)
                    var b=0
                    $(e.target).next().text(jg)
                    $.each($("div[class='" + x2 + "z']"), function (i, obj) {
                        console.log(obj)
                        if ($(obj).text() != null) {
                            b = b + $(obj).text()*1
                        }
                    })
                    var a = b * SH
                    console.log(b)
                    console.log(a)
                    console.log(jgf)
                    $(e.target).parent().parent().children().eq(6).text(b + a + jgf)
                    var x1 = $(e.target).parent().parent().children().first().next().next().text()//物料名

                    $.each($("th[class='" + x1 + "']").get(), function (i, item) {
                        if (item.id == x1) {
                            $(item).text((b + a + jgf).toFixed(4))
                            var th = $(item).text()
                            var pr = $(item).prev().text()
                            $(item).next().text((pr / th).toFixed(4)*100)+"%"
                        }
                    })

                }

            })
            //计算瓦楞平方价格
            $(document).on("change", ".JS_WLKZ", function (e) {
                var ycfz = null
                var MK = $(e.target).val();//平方克重
                var ML = $(e.target).parent().parent().prev().children().first().val();//瓦楞系数
                var MB = $(e.target).parent().parent().prev().prev().children().first().val();//瓦楞系数
                var PFJG = $("#CHJG").text()
                $.ajax({
                    url: "/Procure/pricing_New_2",
                    type: 'GET',
                    data: { "MB": MB, "ML": ML, "state": 6 },
                    success: function (data) {
                        JSJG(data)
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
                function JSJG(date) {
                    $.each(date, function (i, item) {
                        ycfz = item.PA_price
                    })
                    var jg = (ycfz * 0.000001 * MK)
                    $(e.target).parent().next().text(jg)
                    var b = $("div[id='Z1']").text() * 1 + $("div[id='Z2']").text() * 1 + $("div[id='Z3']").text() * 1 + $("div[id='Z4']").text() * 1 + $("div[id='Z5']").text() * 1
                    var a = b * SH
                    $(e.target).parent().parent().children().first().next().next().next().next().next().next().text(b + a + jgf)
                }
            })
        })
    </script>
}